package com.hrms.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hrms.Bean.PageBean;
import com.hrms.domain.Employee;
import com.hrms.mapper.EmployeeMapper;
import com.hrms.service.EmployeeService;
import com.hrms.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author:zhao xinyu
 * @date: 2024/12/19 - 12:35
 * @mail: zxy1277692924@outlook.com
 * @info:
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper empMapper;
    @Autowired
    private EmployeeMapper employeeMapper;

    public PageBean page(Integer page, Integer pageSize) {
        //1. 设置分页参数
        PageHelper.startPage(page,pageSize);
        //2. 执行查询
        Page<Employee> empPage = empMapper.selectEmployeeList();
        //3. 封装结果
        return new PageBean(empPage.getTotal(),empPage.getResult());
    }

    /**
     * 查询员工管理列表
     *
     * @param employee 员工管理
     * @return 员工管理
     */
    @Override
    public List<Employee> selectEmployeeList(Employee employee)
    {
        return empMapper.selectEmployeeList(employee);
    }

    @Override
    public int insertEmployee(Employee employee)
    {
        employee.setCreateTime(DateUtils.getNowDate());
        employee.setModifyTime(DateUtils.getNowDate());
        return employeeMapper.insertEmployee(employee);
    }
}
